/**
 * Created by Administrator on 2017/8/28.
 */
import AppService from '../../common/utils/app.service'

// const URL_PRE = 'admin/adminusers'
// const ROLE = 'admin/roles'

export function getAdminList(params, dispatch) {
    return AppService.getRequest('/admin/adminuser/getAdminUserList', {...params}).then(response => {
        if (response.errorCode == 0) {
            // dispatch({
            //     type: 'ADMIN_LIST',
            //     list: response.body.rows,
            // })
        }
        return response
    })
}

export function getAdmin(id) {
    return AppService.getRequest(`/admin/adminuser/get/`, {id: id})
}
export function addAdmin(params) {
    return AppService.postRequest(`/admin/adminuser/create`, params)
}
export function editAdmin(params) {
    return AppService.postRequest(`/admin/adminuser/update`, params)
}
export function deleteAdmin(id) {
    return AppService.postRequest(`/admin/adminuser/delete`,{
        id: id
    })
}

export function enableAdmin(id) {
    return AppService.postRequest(`/admin/adminuser/enable`, {
        id: id
    })
}

export function disableAdmin(id) {
    return AppService.postRequest(`/admin/adminuser/disable`, {
        id: id
    })
}

export function getRoleList(params) {
    return AppService.getRequest('/admin/role', params)
}

export function getRole(id) {
    return AppService.getRequest(`/admin/role/get/`, {id: id})
}

export function deleteRole(id) {
    return AppService.postRequest(`/admin/role/delete/`, {id: id})
}

export function addRole(params) {
    return AppService.postRequest('/admin/role/create', params)
}

export function editRole(params) {
    console.warn(params.permission);
    return AppService.postRequest(`/admin/role/update/`, params)
}
//获取权限列表
export function getPermissionList() {
    return AppService.getRequest('/admin/permission/getPermissionList')
}

//获得省的数据
export function getProviceData() {
    return AppService.getRequest('/base/address/province/list')
}
//根据省份获取城市的数据
export function getCityData(params) {
    return AppService.getRequest('/base/address/city/list', params)
}
export function getChannel() {
    return AppService.getRequest('/admin/channel/all', {})
}

//用户管理
export function getUserList(params) {
    return AppService.getRequest('admin/user/getUserList', params)
}
export function DisableUser(params) {
    return AppService.postRequest('admin/user/disable', params)
}
export function EnableUser(params) {
    return AppService.postRequest('admin/user/enable', params)
}
export function getUserDetail(id) {
    return AppService.getRequest(`/admin/user/get`,{id})
}

//活动规则
export function getBaseSettingDetail() {
    return AppService.getRequest(`/admin/baseSetting/detail`)
}
export function updateBaseSetting(id,params) {
    return AppService.postRequest(`/admin/baseSetting/update`,{...params})
}